package com.hqyj.controller;

import com.hqyj.pojo.SysMenu;
import com.hqyj.service.MenuService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

import java.util.HashMap;

@RequestMapping("/menu")
@Controller
public class SysMenuController {

    @Autowired
    private MenuService menuService;

    @RequestMapping("/addMenu")
    public String addMenu() {
        return "menu/menu-add";
    }

    //处理添加新菜的Ajax
    @RequestMapping("/addAjax")
    @ResponseBody
    public HashMap<String, Object> addAjax(SysMenu menu) {
        return menuService.addMenu(menu);
    }

    //查看所有主食
    @RequestMapping("/menuList1")
    public String menuList1() {
        return "menu/menulist1";
    }

    @RequestMapping("/listAjax1")
    @ResponseBody
    public HashMap<String, Object> listAjax1(SysMenu menu) {
        return menuService.menuList(menu);
    }

    //查看所有甜点
    @RequestMapping("/menuList2")
    public String menuList2() {
        return "menu/menulist2";
    }

    @RequestMapping("/listAjax2")
    @ResponseBody
    public HashMap<String, Object> listAjax2(SysMenu menu) {
        return menuService.menuList(menu);
    }

    //查看所有酒水
    @RequestMapping("/menuList3")
    public String menuList3() {
        return "menu/menulist3";
    }


    @RequestMapping("/listAjax3")
    @ResponseBody
    public HashMap<String, Object> listAjax3(SysMenu menu) {
        return menuService.menuList(menu);
    }

    //查看所有菜品
    @RequestMapping("/menuList")
    public String menuList() {
        return "menu/menulist-delete";
    }

    @RequestMapping("/listAjax")
    @ResponseBody
    public HashMap<String, Object> listAjax(SysMenu menu) {
        return menuService.menuListAll(menu);
    }

    //点餐
    @RequestMapping("/orderAjax")
    @ResponseBody
    public HashMap<String, Object> orderAjax(SysMenu menu) {
        return menuService.order(menu);
    }

    //批量删除的ajax请求
    @RequestMapping("/delAjax")
    @ResponseBody
    public HashMap<String, Object> delAjax(String arrId) {
        return menuService.bitDel(arrId);
    }

}
